/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Entity;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Collection;
import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author HOME
 */
@Entity
@Table(name = "BANKS_IN_REGIONS")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "BanksInRegions.findAll", query = "SELECT b FROM BanksInRegions b"),
    @NamedQuery(name = "BanksInRegions.findByBankRegionId", query = "SELECT b FROM BanksInRegions b WHERE b.bankRegionId = :bankRegionId"),
    @NamedQuery(name = "BanksInRegions.findByRequisites", query = "SELECT b FROM BanksInRegions b WHERE b.requisites = :requisites"),
    @NamedQuery(name = "BanksInRegions.findByRatesPageUrl", query = "SELECT b FROM BanksInRegions b WHERE b.ratesPageUrl = :ratesPageUrl")})
public class BanksInRegions implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Id
    //@Basic(optional = false)
    //@NotNull
    @Column(name = "BANK_REGION_ID")
    private BigDecimal bankRegionId;
    @Size(max = 1024)
    @Column(name = "REQUISITES")
    private String requisites;
    @Size(max = 2048)
    @Column(name = "RATES_PAGE_URL")
    private String ratesPageUrl;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bankRegionId")
    private Collection<Branches> branchesCollection;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "banksInRegions")
    private Collection<Rates> ratesCollection;
    @JoinColumn(name = "REGION_ID", referencedColumnName = "REGION_ID")
    @ManyToOne(optional = false)
    private Regions regionId;
    @JoinColumn(name = "BANK_ID", referencedColumnName = "BANK_ID")
    @ManyToOne(optional = false)
    private Banks bankId;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "bankRegionId")
    private Collection<Templates> templatesCollection;

    public BanksInRegions() {
    }

    public BanksInRegions(BigDecimal bankRegionId) {
        this.bankRegionId = bankRegionId;
    }

    public BigDecimal getBankRegionId() {
        return bankRegionId;
    }

    public void setBankRegionId(BigDecimal bankRegionId) {
        this.bankRegionId = bankRegionId;
    }

    public String getRequisites() {
        return requisites;
    }

    public void setRequisites(String requisites) {
        this.requisites = requisites;
    }

    public String getRatesPageUrl() {
        return ratesPageUrl;
    }

    public void setRatesPageUrl(String ratesPageUrl) {
        this.ratesPageUrl = ratesPageUrl;
    }

    @XmlTransient
    public Collection<Branches> getBranchesCollection() {
        return branchesCollection;
    }

    public void setBranchesCollection(Collection<Branches> branchesCollection) {
        this.branchesCollection = branchesCollection;
    }

    @XmlTransient
    public Collection<Rates> getRatesCollection() {
        return ratesCollection;
    }

    public void setRatesCollection(Collection<Rates> ratesCollection) {
        this.ratesCollection = ratesCollection;
    }

    public Regions getRegionId() {
        return regionId;
    }

    public void setRegionId(Regions regionId) {
        this.regionId = regionId;
    }

    public Banks getBankId() {
        return bankId;
    }

    public void setBankId(Banks bankId) {
        this.bankId = bankId;
    }

    @XmlTransient
    public Collection<Templates> getTemplatesCollection() {
        return templatesCollection;
    }

    public void setTemplatesCollection(Collection<Templates> templatesCollection) {
        this.templatesCollection = templatesCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (bankRegionId != null ? bankRegionId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof BanksInRegions)) {
            return false;
        }
        BanksInRegions other = (BanksInRegions) object;
        if ((this.bankRegionId == null && other.bankRegionId != null) || (this.bankRegionId != null && !this.bankRegionId.equals(other.bankRegionId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return this.regionId.getRegionName() + "  " + this.bankId.getBankName();
    }
    
}
